package com.kim.nidoya.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kim.nidoya.R;

public class MediaCenterTitleAdapter extends MediaCenterBaseAdapter<String> {

	private boolean showTitleLeft = false;

	public void setShowTitleLeft(boolean showTitleLeft) {
		this.showTitleLeft = showTitleLeft;
	}

	public MediaCenterTitleAdapter(Context context, List<String> dataList) {
		super(context, dataList);
	}

	public MediaCenterTitleAdapter(Context context, String[] dataArray) {
		super(context, dataArray);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.media_list_item, null);
			holder = new ViewHolder();
			holder.titleLeft = (TextView) convertView
					.findViewById(R.id.txt_title_left);
			holder.title = (TextView) convertView.findViewById(R.id.txt_title);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (showTitleLeft) {
			holder.titleLeft.setVisibility(View.VISIBLE);
			holder.title.setVisibility(View.GONE);
			holder.titleLeft.setText(this.dataArray[position]);
		} else {
			holder.title.setVisibility(View.VISIBLE);
			holder.titleLeft.setVisibility(View.GONE);
			holder.title.setText(this.dataArray[position]);
		}
		return convertView;
	}

	private final class ViewHolder {
		TextView titleLeft;
		TextView title;
	}
}
